//===================================================================================
// $$
//
// Coder: Code Milker v1.0
// 0 - EntityName
// 1 - Properties
//===================================================================================

namespace App.Domain.Handlers {
    using App.Data;
    using App.Domain.Contracts;
    using App.Domain.Models;
    using System;

    public class UpdateRecruiter {
        private readonly IRecruiterRepository _recruiterRepository;

        public UpdateRecruiter( IRecruiterRepository recruiterRepository) {
            _recruiterRepository = recruiterRepository;
        }

        public void Execute(ICreateRecruiterCommand recruiterForm) {
            try {
                var existing = _recruiterRepository.GetRecruiter(recruiterForm.Id);
                var recruiter = recruiterForm.ConvertToEntity();

                _recruiterRepository.Update(recruiter);
            }
            catch (InvalidOperationException ex) {
                throw new BusinessServicesException("CannotFindVehicleToUpdateExceptionMessage", ex);
            }
        }
    }
}
